package com.neu.flashmall.order.controller;

import com.neu.common.utils.Result;
import com.neu.flashmall.order.service.OmsOrderItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/oms_orderItem")
@Api(value = "子订单Controller")
public class OmsOrderItemController {
    @Resource
    private OmsOrderItemService omsOrderItemService;

    @GetMapping("/getPaged")
    @ApiOperation(value = "根据orderId查询子订单")
    public Result getPaged(@RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "3") Integer pageSize,
                           @Param(value = "orderId") Long orderId){
        //orderCode,spuName,spuBrand,skuName,skuPrice,skuQuantity,skuAttrsVals,realAmount
        return Result.ok().put(omsOrderItemService.getPaged(pageNum,pageSize,orderId));
    }

    @GetMapping("/selectAll")
    @ApiOperation(value = "根据orderId获得子订单信息")
    public Result selectAll(@Param(value = "orderId") Long orderId){

        return Result.ok().put(omsOrderItemService.selectAll(orderId));
    }
}
